﻿using System.Data;

namespace DAL
{
    public static class sad_License
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-License]
        public static DataTable GetLicense()
        {
            Cls.CreateNewSqlCommand();
            return Cls.GetData("sad_License");
        }
        #endregion

        #region[Register-License]
        public static bool RegisterLicense(LicenseEt data)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", data.Id);
            Cls.AddParameter("@Customer", data.Customer);
            Cls.AddParameter("@LicenseType", data.LicenseType);
            Cls.AddParameter("@License", data.License);
            Cls.AddParameter("@Key", data.Key);
            Cls.AddParameter("@Version", data.Version);
            return Cls.ExecuteNonQuery("sad_RegisterLicense");
        }
        #endregion

        #region[Register-License-Create]
        public static bool RegisterLicenseCreate(LicenseEt data)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Customer", data.Customer);
            Cls.AddParameter("@LicenseType", data.LicenseType);
            Cls.AddParameter("@License", data.License);
            Cls.AddParameter("@Key", data.Key);
            Cls.AddParameter("@Version", data.Version);
            Cls.AddParameter("@UserQuantity", data.Version);
            Cls.AddParameter("@Note", data.Version);
            return Cls.ExecuteNonQuery("sad_CreateRegisterLicense");
        }
        #endregion
    }
    public class LicenseEt
    {
        public string Customer { get; set; }
        public string LicenseType { get; set; }
        public string License { get; set; }
        public string Version { get; set; }
        public int Id { get; set; }
        public string Key { get; set; }
    }
}